

package org.come.starcard;

import com.tool.btn.FormsOnOffBtn;
import com.tool.tcpimg.UIUtils;
import com.updateNew.MyIsif;

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.LayoutManager;
import java.math.BigDecimal;
import java.util.ArrayList;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import org.come.entity.Goodstable;
import org.come.until.GoodsListFromServerUntil;

 

public class JpanelSoulBackMain extends JPanel {
    private JLabel[] cardLab;
    private BtnStarCard yesBtn;
    private BtnStarCard noBtn;
    private ArrayList<BigDecimal> starCardList;
    private ImageIcon iconBack;

    public JpanelSoulBackMain() {
    		setPreferredSize(new Dimension(377, 311));
            setLayout(null);
            setOpaque(false);
            // 关闭按钮事件
            FormsOnOffBtn offBtn = new FormsOnOffBtn("inkImg/old/2/1.png", 1, 96);
            offBtn.setBounds(377 - 37, 10, 25, 25);
            this.add(offBtn);
            getCardLab();
            getNoBtn();
            getYesBtn();
            getStarCardList();
    }

    public void addListNum(Goodstable goodstable) {
        BigDecimal rgid = goodstable.getRgid();
        if (this.starCardList.contains(rgid)) {
            this.starCardList.remove(rgid);
        } else {
            this.starCardList.add(rgid);
        }

    }

    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        	if (iconBack == null) {
                iconBack = new ImageIcon("inkImg/newbackground/B292.png");
            }
            g.drawImage(iconBack.getImage(), 0, 0, 377, 311, this);
            GoodsListFromServerUntil.drawStarCardImg(g, 47, 57, starCardList);
    }

    public ImageIcon getIconBack() {
        return this.iconBack;
    }

    public void setIconBack(ImageIcon iconBack) {
        this.iconBack = iconBack;
    }

    public JLabel[] getCardLab() {
        if (this.cardLab == null) {
            this.cardLab = new JLabel[24];
            	for (int i = 0; i < cardLab.length; i++) {
                    cardLab[i] = new JLabel();
                    cardLab[i].setBounds(47 + i % 6 * 51, 57 + i / 6 * 51, 50, 50);
                    cardLab[i].setOpaque(false);
                    cardLab[i].addMouseListener(new MouseListenerSoulBack(i, this));
                    this.add(cardLab[i]);
                }
        }

        return this.cardLab;
    }

    public void setCardLab(JLabel[] cardLab) {
        this.cardLab = cardLab;
    }

    public BtnStarCard getYesBtn() {
        if (this.yesBtn == null) {
        		yesBtn = new BtnStarCard("skin/8100226/newbutton/B20.png", 1, UIUtils.COLOR_WHITE2, UIUtils.TEXT_HY16, "确 认", 30,
                        this);
                yesBtn.setBounds(70, 270, 59, 24);
            this.add(this.yesBtn);
        }

        return this.yesBtn;
    }

    public void setYesBtn(BtnStarCard yesBtn) {
        this.yesBtn = yesBtn;
    }

    public BtnStarCard getNoBtn() {
        if (this.noBtn == null) {
        		noBtn = new BtnStarCard("skin/8100226/newbutton/B20.png", 1, UIUtils.COLOR_WHITE2, UIUtils.TEXT_HY16, "取消", 31,
                        this);
                noBtn.setBounds(220, 270, 59, 24);
            this.add(this.noBtn);
        }

        return this.noBtn;
    }

    public void setNoBtn(BtnStarCard noBtn) {
        this.noBtn = noBtn;
    }

    public ArrayList<BigDecimal> getStarCardList() {
        if (this.starCardList == null) {
            this.starCardList = new ArrayList();
        }

        return this.starCardList;
    }

    public void setStarCardList(ArrayList<BigDecimal> starCardList) {
        this.starCardList = starCardList;
    }
}
